package com.itheima.homework;

public class Demo3 {
    public static void main(String[] args) {
        int[] arr={1,2,3,4,5,6};
        wei(1,5,arr);
    }

    public static void wei(int a, int b, int[] arr){


        if(a<=arr.length && b<=arr.length) {
            int c=arr[a];
            int d=arr[b];
            arr[a] = d;
            arr[b] = c;
            for (int i = 0; i < arr.length; i++) {
                System.out.print(arr[i] + " ");
            }

        }else
            System.out.println("本次输出有误");

    }

}
